﻿Imports PTIC_GestionExcel
Imports PTIC_GestionBDD
Imports PTIC_Util
Imports Microsoft.Office.Interop

Public Class frmResultatsEcheancier
    Implements PTIC_Util.IObserver

#Region "Variables de classe"

    Protected _universBDD As UniversOMANE
    Protected _controleurOMANE As Controleur


#Region "Gestion de l'affichage"
    Protected m_blockMAJmodeleFromAff As Boolean = False
#End Region

#End Region

#Region "Création d'une instance"
    Public Sub New(ByVal univers As UniversOMANE, _
                   ByVal controleur As Controleur)
        ' Cet appel est requis par le Concepteur Windows Form.
        InitializeComponent()
        _universBDD = univers
        _controleurOMANE = controleur
        initCbx()
        refreshAll()
        _universBDD.listeTraitements.getTraitMoteurEcheancier.ajouteObserver(Me)
    End Sub
    Public Sub initCbx()

        _controleurOMANE.controleTraitements.controleEcheancier.setRecalcul(typeRecalcul.SurOrdre)

        Dim dv_vueMort As DataView = New DataView()
        dv_vueMort.Table = _universBDD.refListeTablesReferentiel
        dv_vueMort.RowFilter = "strTypeTable='DC'"
        cbx_TableMort.DisplayMember = "strNomTable"
        cbx_TableMort.ValueMember = "strNomFichier"
        cbx_TableMort.DataSource = dv_vueMort

        _controleurOMANE.controleTraitements.controleEcheancier.setRecalcul(typeRecalcul.Automatique)

        Dim dv_vueINCINV As DataView = New DataView()
        dv_vueINCINV.Table = _universBDD.refListeTablesReferentiel
        dv_vueINCINV.RowFilter = "strTypeTable='MAINTINCINV_NB_MENS'"
        cbx_TbleMaintINCINV.DisplayMember = "strNomTable"
        cbx_TbleMaintINCINV.ValueMember = "strNomFichier"
        cbx_TbleMaintINCINV.DataSource = dv_vueINCINV

    End Sub
#End Region

#Region "Interception des évènements sur les contrôles de la feuille"
#Region "Taux nominal"
    Private Sub txtTxNom_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtTxNom.Validating
        If Not IsNumeric(txtTxNom.Text) Then
            e.Cancel = True
            txtTxNom.Select(0, txtTxNom.Text.Length)
            ErrorProvider1.SetError(txtTxNom, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtTxNom.Text) < 1 Then
            e.Cancel = True
            txtTxNom.Select(0, txtTxNom.Text.Length)
            ErrorProvider1.SetError(txtTxNom, "Le taux nominal doit être inférieur à 1")
        End If
        If Not CDbl(txtTxNom.Text) > 0 Then
            e.Cancel = True
            txtTxNom.Select(0, txtTxNom.Text.Length)
            ErrorProvider1.SetError(txtTxNom, "Le taux nominal doit être supérieur à 0")
        End If
    End Sub
    Private Sub txtTxNom_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTxNom.Validated
        _controleurOMANE.controleTraitements.controleEcheancier.setTxNom(txtTxNom.value)
    End Sub
#End Region
#Region "Capital initial"
    Private Sub txtCapIni_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtCapIni.Validating
        If Not IsNumeric(txtCapIni.Text) Then
            e.Cancel = True
            txtCapIni.Select(0, txtCapIni.Text.Length)
            ErrorProvider1.SetError(txtCapIni, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtCapIni.Text) > 0 Then
            e.Cancel = True
            txtCapIni.Select(0, txtCapIni.Text.Length)
            ErrorProvider1.SetError(txtCapIni, "Le capital initial doit être supérieur à 0")
        End If
    End Sub
    Private Sub txtCapIni_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCapIni.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getcapIni <> CDbl(txtCapIni.value) Then .setcapIni(CDbl(txtCapIni.value))
        End With
    End Sub
#End Region
#Region "Durée de projection en mois"
    Private Sub TxtLongueurProj_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtLongueurProj.Validated
        ErrorProvider1.SetError(TxtLongueurProj, "")
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getLongueurProj <> CDbl(TxtLongueurProj.value) Then .setLongueurProj(CInt(TxtLongueurProj.value))
        End With
    End Sub
    Private Sub TxtLongueurProj_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TxtLongueurProj.Validating
        If Not IsNumeric(TxtLongueurProj.Text) Then
            e.Cancel = True
            TxtLongueurProj.Select(0, TxtLongueurProj.Text.Length)
            ErrorProvider1.SetError(TxtLongueurProj, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(TxtLongueurProj.Text) < 1000 Then
            e.Cancel = True
            TxtLongueurProj.Select(0, TxtLongueurProj.Text.Length)
            ErrorProvider1.SetError(TxtLongueurProj, "Le nombre de périodes saisi est trop important")
        End If
    End Sub
#End Region
#Region "Age à la souscription"
    Private Sub TxtAgeInit_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TxtAgeInit.Validating
        If Not IsNumeric(TxtAgeInit.Text) Then
            e.Cancel = True
            TxtAgeInit.Select(0, TxtAgeInit.Text.Length)
            ErrorProvider1.SetError(TxtAgeInit, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(TxtAgeInit.Text) < 120 Then
            e.Cancel = True
            TxtAgeInit.Select(0, TxtAgeInit.Text.Length)
            ErrorProvider1.SetError(TxtAgeInit, "Le nombre saisi est invalide")
        End If
    End Sub
    Private Sub TxtAgeInit_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtAgeInit.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getAgeInit <> CDbl(TxtAgeInit.value) Then .setAgeInit(CDbl(TxtAgeInit.value))
        End With
    End Sub
#End Region
#Region "Taux de remboursements anticipés"
    Private Sub txtTxRembAnt_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtTxRembAnt.Validating
        If Not IsNumeric(txtTxRembAnt.Text) Then
            e.Cancel = True
            txtTxRembAnt.Select(0, txtTxRembAnt.Text.Length)
            ErrorProvider1.SetError(txtTxRembAnt, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtTxRembAnt.Text) >= 0 Then
            e.Cancel = True
            txtTxRembAnt.Select(0, txtTxRembAnt.Text.Length)
            ErrorProvider1.SetError(txtTxRembAnt, "Le taux de remboursements anticipés ne peut être inférieur à 0")
        End If
    End Sub
    Private Sub txtTxRembAnt_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTxRembAnt.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            _controleurOMANE.controleTraitements.controleEcheancier.setTxRembAnti(txtTxRembAnt.value)
        End With
    End Sub
#End Region
#Region "Nombre d'assurés la 1ere année"
    Private Sub txtnbAssIni_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtnbAssIni.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getNbInitAssures <> CDbl(txtnbAssIni.value) Then .setNbInitAssures(CDbl(txtnbAssIni.value))
        End With
    End Sub
    Private Sub txtnbAssIni_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtnbAssIni.Validating
        If Not IsNumeric(txtnbAssIni.Text) Then
            e.Cancel = True
            txtnbAssIni.Select(0, txtnbAssIni.Text.Length)
            ErrorProvider1.SetError(txtnbAssIni, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtnbAssIni.Text) >= 0 Then
            e.Cancel = True
            txtnbAssIni.Select(0, txtnbAssIni.Text.Length)
            ErrorProvider1.SetError(txtnbAssIni, "Le nombre initial d'assuré doit être positif")
        End If
    End Sub
#End Region
#Region "Taux d'entrée en INCAP/INVAL"
    Private Sub txtTxEntree_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTxEntree.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getTxEntreeINCINV <> CDbl(txtTxEntree.value) Then .setTxEntreeINCINV(CDbl(txtTxEntree.value))
        End With
    End Sub
    Private Sub txtTxEntree_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtTxEntree.Validating
        If Not IsNumeric(txtTxEntree.Text) Then
            e.Cancel = True
            txtTxEntree.Select(0, txtTxEntree.Text.Length)
            ErrorProvider1.SetError(txtTxEntree, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtTxEntree.Text) >= 0 Then
            e.Cancel = True
            txtTxEntree.Select(0, txtTxEntree.Text.Length)
            ErrorProvider1.SetError(txtTxEntree, "Le taux d'entrée en INCAP/INVAL doit être positif")
        End If
    End Sub
#End Region
#Region "Taux de taxe DC"
    Private Sub txtTaxeDC_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTaxeNonVie.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getTxTaxeDC <> CDbl(txtTaxeNonVie.value) Then .setTxTaxeDC(CDbl(txtTaxeNonVie.value))
        End With
    End Sub
    Private Sub txtTaxeDC_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtTaxeNonVie.Validating
        If Not IsNumeric(txtTaxeNonVie.Text) Then
            e.Cancel = True
            txtTaxeNonVie.Select(0, txtTaxeNonVie.Text.Length)
            ErrorProvider1.SetError(txtTaxeNonVie, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtTaxeNonVie.Text) >= 0 Then
            e.Cancel = True
            txtTaxeNonVie.Select(0, txtTaxeNonVie.Text.Length)
            ErrorProvider1.SetError(txtTaxeNonVie, "La taxe décès doit être positive ou nulle")
        End If
    End Sub
#End Region
#Region "Taux de frais de gestion"
    Private Sub txtFG_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFG.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getTxFG <> CDbl(txtFG.value) Then .setTxFG(CDbl(txtFG.value))
        End With
    End Sub
    Private Sub txtFG_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtFG.Validating
        If Not IsNumeric(txtFG.Text) Then
            e.Cancel = True
            txtFG.Select(0, txtFG.Text.Length)
            ErrorProvider1.SetError(txtFG, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtFG.Text) >= 0 Then
            e.Cancel = True
            txtFG.Select(0, txtFG.Text.Length)
            ErrorProvider1.SetError(txtFG, "LE taux de frais de gestion doit être positif ou nul")
        End If
    End Sub
#End Region
#Region "Taux technique"
    Private Sub txtTxTech_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTxTech.Validated
        With _controleurOMANE.controleTraitements.controleEcheancier
            If .getTxTech <> CDbl(txtTxTech.value) Then .setTxTech(CDbl(txtTxTech.value))
        End With
    End Sub
    Private Sub txtTxTech_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtTxTech.Validating
        If Not IsNumeric(txtTxTech.Text) Then
            e.Cancel = True
            txtTxTech.Select(0, txtTxTech.Text.Length)
            ErrorProvider1.SetError(txtTxTech, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtTxTech.Text) >= 0 Then
            e.Cancel = True
            txtTxTech.Select(0, txtTxTech.Text.Length)
            ErrorProvider1.SetError(txtTxTech, "Le taux technique doit être positif ou nul")
        End If
    End Sub
#End Region
#Region "Tarif An INCAP/INVAL"
    Private Sub txtTarifINCINV_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTarifINCINV.Validated
        With _controleurOMANE.controleTraitements.controleEcheancier
            If .getTarifINCINV <> CDbl(txtTarifINCINV.value) Then .setTarifINCINV(CDbl(txtTarifINCINV.value))
        End With
    End Sub
    Private Sub txtTarifINCINV_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtTarifINCINV.Validating
        If Not IsNumeric(txtTarifINCINV.Text) Then
            e.Cancel = True
            txtTxTech.Select(0, txtTarifINCINV.Text.Length)
            ErrorProvider1.SetError(txtTarifINCINV, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtTarifINCINV.Text) >= 0 Then
            e.Cancel = True
            txtTarifINCINV.Select(0, txtTarifINCINV.Text.Length)
            ErrorProvider1.SetError(txtTarifINCINV, "Le tarif INCAP/INVAL doit être positif ou nul")
        End If
    End Sub
#End Region
#Region "Tarif An DC"
    Private Sub txtTarifDC_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTarifDC.Validated
        With _controleurOMANE.controleTraitements.controleEcheancier
            If .getTarifDC <> CDbl(txtTarifDC.value) Then .setTarifDC(CDbl(txtTarifDC.value))
        End With
    End Sub
    Private Sub txtTarifDC_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtTarifDC.Validating
        If Not IsNumeric(txtTarifDC.Text) Then
            e.Cancel = True
            txtTarifDC.Select(0, txtTarifDC.Text.Length)
            ErrorProvider1.SetError(txtTarifDC, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtTarifDC.Text) >= 0 Then
            e.Cancel = True
            txtTarifDC.Select(0, txtTarifDC.Text.Length)
            ErrorProvider1.SetError(txtTarifDC, "Le tarif DC doit être positif ou nul")
        End If
    End Sub
#End Region
#Region "Age fin INC/INV"
    Private Sub txtAgeFinINCINV_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtAgeFinINCINV.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getAgeFinINCINV <> CDbl(txtAgeFinINCINV.value) Then .setAgeFinINCINV(CDbl(txtAgeFinINCINV.value))
        End With
    End Sub
    Private Sub txtAgeFinINCINV_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtAgeFinINCINV.Validating
        If Not IsNumeric(txtAgeFinINCINV.Text) Then
            e.Cancel = True
            txtAgeFinINCINV.Select(0, txtAgeFinINCINV.Text.Length)
            ErrorProvider1.SetError(txtAgeFinINCINV, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtAgeFinINCINV.Text) >= 0 Then
            e.Cancel = True
            txtAgeFinINCINV.Select(0, txtAgeFinINCINV.Text.Length)
            ErrorProvider1.SetError(txtAgeFinINCINV, "L'âge de fin de la garantie INCAP/INVAL doit être positif ou nul")
        End If
    End Sub
#End Region
#Region "Age fin DC"
    Private Sub txtAgeFinDC_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtAgeFinDC.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getAgeFinDC <> CDbl(txtAgeFinDC.value) Then .setAgeFinDC(CDbl(txtAgeFinDC.value))
        End With
    End Sub
    Private Sub txtAgeFinDC_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtAgeFinDC.Validating
        If Not IsNumeric(txtAgeFinDC.Text) Then
            e.Cancel = True
            txtAgeFinDC.Select(0, txtAgeFinDC.Text.Length)
            ErrorProvider1.SetError(txtAgeFinDC, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtAgeFinDC.Text) >= 0 Then
            e.Cancel = True
            txtAgeFinDC.Select(0, txtAgeFinDC.Text.Length)
            ErrorProvider1.SetError(txtAgeFinDC, "L'âge de fin de la garantie DC doit être positif ou nul")
        End If
    End Sub
#End Region
#Region "Tx Com Partenaire"
    Private Sub txtTxCom_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTxCom.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getTxComPartenaire <> CDbl(txtTxCom.value) Then .setTxComPartenaire(CDbl(txtTxCom.value))
        End With
    End Sub
    Private Sub txtTxCom_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtTxCom.Validating
        If Not IsNumeric(txtTxCom.Text) Then
            e.Cancel = True
            txtTxCom.Select(0, txtTxCom.Text.Length)
            ErrorProvider1.SetError(txtTxCom, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtTxCom.Text) >= 0 Then
            e.Cancel = True
            txtTxCom.Select(0, txtTxCom.Text.Length)
            ErrorProvider1.SetError(txtTxCom, "Le taux de commissionnement doit être positif ou nul")
        End If
    End Sub
#End Region
#Region "Abattement MNO"
    Private Sub txtAbatMNO_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtAbatMNO.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getAbtMNO <> CDbl(txtAbatMNO.value) Then .setAbtMNO(CDbl(txtAbatMNO.value))
        End With
    End Sub
    Private Sub txtAbatMNO_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtAbatMNO.Validating
        If Not IsNumeric(txtAbatMNO.Text) Then
            e.Cancel = True
            txtAbatMNO.Select(0, txtAbatMNO.Text.Length)
            ErrorProvider1.SetError(txtAbatMNO, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtAbatMNO.Text) >= 0 Then
            e.Cancel = True
            txtAbatMNO.Select(0, txtAbatMNO.Text.Length)
            ErrorProvider1.SetError(txtAbatMNO, "Le taux d'abattement pour exclusion des maladies non objectivables doit être positif ou nul")
        End If
    End Sub
#End Region
#Region "Abattement perte de revenus"
    Private Sub txtPerteRev_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPerteRev.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getAbtPerteRev <> CDbl(txtPerteRev.value) Then .setAbtPerteRev(CDbl(txtPerteRev.value))
        End With
    End Sub
    Private Sub txtPerteRev_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtPerteRev.Validating
        If Not IsNumeric(txtPerteRev.Text) Then
            e.Cancel = True
            txtPerteRev.Select(0, txtPerteRev.Text.Length)
            ErrorProvider1.SetError(txtPerteRev, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtPerteRev.Text) >= 0 Then
            e.Cancel = True
            txtPerteRev.Select(0, txtPerteRev.Text.Length)
            ErrorProvider1.SetError(txtPerteRev, "Le taux d'abattement pour prise en compte de la perte de revenus doit être positif ou nul")
        End If
    End Sub
#End Region
#Region "Majoration sinistres DC"
    Private Sub txtMajSinDC_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMajSinDC.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getMajSinDC <> CDbl(txtMajSinDC.value) Then .setMAJsinDC(CDbl(txtMajSinDC.value))
        End With
    End Sub
    Private Sub txtMajSinDC_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtMajSinDC.Validating
        If Not IsNumeric(txtMajSinDC.Text) Then
            e.Cancel = True
            txtMajSinDC.Select(0, txtMajSinDC.Text.Length)
            ErrorProvider1.SetError(txtMajSinDC, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtMajSinDC.Text) >= 0 Then
            e.Cancel = True
            txtMajSinDC.Select(0, txtMajSinDC.Text.Length)
            ErrorProvider1.SetError(txtMajSinDC, "Le taux de chargement de sécurité des sinistres DC doit être positif ou nul")
        End If
    End Sub
#End Region
#Region "Majoration sinistres INC/INV"
    Private Sub txtMajSinINCINV_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMajSinINCINV.Validated
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            If .getMajSinINCINV <> CDbl(txtMajSinINCINV.value) Then .setMajSinINCINV(CDbl(txtMajSinINCINV.value))
        End With
    End Sub
    Private Sub txtMajSinINCINV_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtMajSinINCINV.Validating
        If Not IsNumeric(txtMajSinINCINV.Text) Then
            e.Cancel = True
            txtMajSinINCINV.Select(0, txtMajSinINCINV.Text.Length)
            ErrorProvider1.SetError(txtMajSinINCINV, "La valeur saisie n'est pas numérique")
            Exit Sub
        End If
        If Not CDbl(txtMajSinINCINV.Text) >= 0 Then
            e.Cancel = True
            txtMajSinINCINV.Select(0, txtMajSinINCINV.Text.Length)
            ErrorProvider1.SetError(txtMajSinINCINV, "Le taux de chargement de sécurité des sinistres INCAP/INVAL doit être positif ou nul")
        End If
    End Sub
#End Region

    Private Sub cbx_TableMort_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbx_TableMort.SelectedIndexChanged
        'Envoie d'un message au contrôleur indiquant que le nom de la table de mortalité du moteur
        'de calcul de l'échéancier a changé
        _controleurOMANE.controleTraitements.controleEcheancier.setTableMortalite(cbx_TableMort.SelectedValue)
    End Sub
    Private Sub cbx_TbleMaintINCINV_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbx_TbleMaintINCINV.SelectedIndexChanged
        _controleurOMANE.controleTraitements.controleEcheancier.setTableMaintienINCINV(cbx_TbleMaintINCINV.SelectedValue)
    End Sub
    Private Sub rdb_Mens_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdb_Mens.CheckedChanged
        refreshDgvResult()
    End Sub


#Region "La sélection médicale"
    Private Sub btnSelMedic_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSelMedic.Click
        Dim frmSelMedic As New DlgSelMedic(_universBDD.listeTraitements.getTraitMoteurEcheancier.getControleurSelectionMedicale, _
                                           _universBDD.listeTraitements.getTraitMoteurEcheancier)
        frmSelMedic.ShowDialog()
    End Sub
#End Region
#End Region

#Region "Rafraichissements"

#Region "Redirection des rafraichissements demandés par le modèle et le contrôleur"
    ''' <summary>
    ''' Récupération des actualisations demandées par le modèle
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="notification"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function actualise(ByVal sender As Object, ByVal notification As Object) As PTIC_Util.resultatValidationContraintes Implements PTIC_Util.IObserver.actualise
        If TypeOf sender Is Moteur_Echeancier Then
            actualiseFromMoteur2(notification)
        End If
        Return Nothing
    End Function
    Public Sub actualiseFromMoteur2(ByVal notification As Moteur_Echeancier.notification)
        If notification = Moteur_Echeancier.notification.moteur2aEteRecalcule Then
            refreshDgvResult()
            refreshMensualite()
        End If
    End Sub
#End Region

#Region "Rafraichissements élémentaires"
    Public Sub refreshAll()
        With _universBDD.listeTraitements.getTraitMoteurEcheancier
            TxtLongueurProj.value = .getLongueurProj
            TxtAgeInit.value = .getAgeInit
            txtCapIni.value = .getcapIni
            txtTxNom.value = _controleurOMANE.controleTraitements.controleEcheancier.getTxNomAnn()
            txtTxRembAnt.value = _controleurOMANE.controleTraitements.controleEcheancier.getTxRembAntiAnn()
            txtnbAssIni.value = Math.Round(.getNbInitAssures, 3)
            txtTxEntree.value = .getTxEntreeINCINV
            txtTaxeNonVie.value = .getTxTaxeDC
            txtFG.value = .getTxFG
            txtTxTech.value = _controleurOMANE.controleTraitements.controleEcheancier.getTxTech
            txtTarifINCINV.value = _controleurOMANE.controleTraitements.controleEcheancier.getTarifINCINV
            txtTarifDC.value = _controleurOMANE.controleTraitements.controleEcheancier.getTarifDC
            txtAgeFinINCINV.value = .getAgeFinINCINV
            txtAgeFinDC.value = .getAgeFinDC
            txtTxCom.value = .getTxComPartenaire
            txtAbatMNO.value = .getAbtMNO
            txtPerteRev.value = .getAbtPerteRev
            txtMajSinDC.value = .getMajSinDC
            txtMajSinINCINV.value = .getMajSinINCINV
            cbx_TableMort.SelectedValue = _controleurOMANE.controleTraitements.controleEcheancier.getTableMortalite
            cbx_TbleMaintINCINV.SelectedValue = _controleurOMANE.controleTraitements.controleEcheancier.getTableMaintienINCINV
            refreshDgvResult()
            refreshMensualite()
        End With
    End Sub
    Private Sub refreshDgvResult()
        dgv_Resultats.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect
        If rdb_Mens.Checked Then
            If Not _universBDD Is Nothing Then
                'Récupération des résultats dans l'univers de calcul
                Dim resProj As DataTable = CType(_universBDD.listeTraitements.getTraitMoteurEcheancier.getResultats.ProjectionMensuelle, DataTable)
                dgv_Resultats.DataSource = resProj
                dgv_Resultats.Columns("NumMois").Width = 70
                dgv_Resultats.Columns("NumAnnee").Width = 70
                dgv_Resultats.Columns("IndAnneePleine").Visible = False
                dgv_Resultats.Columns("EchDeb").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("EchFin").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("AgeActuMilPer").DefaultCellStyle.Format = "#,###.##"
                dgv_Resultats.Columns("TxMortMilPer").DefaultCellStyle.Format = "0.##00%"
                dgv_Resultats.Columns("NbCotisantsDebPer").DefaultCellStyle.Format = "#,##0.##"
                dgv_Resultats.Columns("NbCotisants").DefaultCellStyle.Format = "#,##0.##"
                dgv_Resultats.Columns("NbSinDC").DefaultCellStyle.Format = "#,##0.##"
                dgv_Resultats.Columns("NbSinistresINCAPINVALFinPer").DefaultCellStyle.Format = "0.##"
                dgv_Resultats.Columns("CotisCommINCINV").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("CotisCommDC").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("CotisTechINCINV").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("CotisTechDC").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("SinRegDC").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("SinRegINCINV").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("projPMRente").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("ProjPPRC").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("ProjPMDC").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("projPMINCINV").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("ProjCSRDC").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("MSR_Vie").DefaultCellStyle.Format = "#,##0"


            End If
        Else
            If Not _universBDD.listeTraitements.getTraitMoteurEcheancier.getResultats Is Nothing Then
                Dim resProj As DataTable = CType(_universBDD.listeTraitements.getTraitMoteurEcheancier.getResultats.ProjectionAnnuelle, DataTable)
                dgv_Resultats.DataSource = resProj
                dgv_Resultats.Columns("numAnnee").Width = 50
                dgv_Resultats.Columns("CSRDCfin").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("cotisDC").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("sinDC").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("PM_DCtheo").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("cotisIT").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("sinIT").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("PM_Rente").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("PPRC").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("PM_ITtheo").DefaultCellStyle.Format = "#,##0"
                dgv_Resultats.Columns("MSR_Vie").DefaultCellStyle.Format = "#,##0"
            End If
        End If
    End Sub
    Private Sub refreshMensualite()
        txtEch.Text = Format(CType(_universBDD.listeTraitements.getTraitMoteurEcheancier.getResultats.EcheanceMensuelle, Double), "#,###.##")
    End Sub
#End Region

#End Region

End Class